package com.ninetaildemonfox.zdl.socialproject.mvp.ui.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ninetaildemonfox.zdl.socialproject.base.BaseActivity;
import com.ninetaildemonfox.zdl.socialproject.R;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.adapter.PagerFragmentAdapter;
import com.ninetaildemonfox.zdl.socialproject.mvp.ui.fragment.AccountDetailsFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author NineTailDemonFox
 * @date 2019/7/22 16:47
 * 功能描述： 账户明细
 * 联系方式：1037438704@qq.com
 */
public class AccountDetailsActivity extends BaseActivity {
    @BindView(R.id.image_left_finish)
    ImageView imageleftFinish;
    @BindView(R.id.text_center)
    TextView textCenter;
    @BindView(R.id.text_right)
    TextView textRight;
    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    private String[] string = {"全部", "收入", "支出"};
    private List<Fragment> mFragmentList;
    private PagerFragmentAdapter adapter;

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_account_details;
    }

    @Override
    protected void onInitialization(Bundle bundle) {
        initView();
        initData();
    }

    private void initData() {
        textCenter.setText("账户明细");
        imageleftFinish.setVisibility(View.VISIBLE);
        viewPager.setAdapter(adapter);
        viewPager.setOffscreenPageLimit(mFragmentList.size());
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        tabLayout.setupWithViewPager(viewPager);
    }

    private void initView() {
        mFragmentList = new ArrayList<>();
//        type 0 全部 1收入 2支出
        mFragmentList.add(AccountDetailsFragment.newInstance(0));
        mFragmentList.add(AccountDetailsFragment.newInstance(1));
        mFragmentList.add(AccountDetailsFragment.newInstance(2));
        //实例化适配器
        adapter = new PagerFragmentAdapter(getSupportFragmentManager(), mFragmentList, string);
    }

    @OnClick({R.id.image_left_finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.image_left_finish:
                finish();
                break;
            default:
        }
    }
}